package personnel.department.dao.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;


@Entity
@Table(name="degree")
public class Degree implements UniqueObject {

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="id")
	private Long id;

	@OneToOne(cascade=CascadeType.ALL)
	private Diplom diplom;
	
	@Column(name="date_of_assigment")
	private Date dateOfAssigment;

	@Column(name="k_m_n")
	private Boolean kmn;

	@Column(name="d_m_n")
	private Boolean dmn;
	
	@ManyToOne(cascade=CascadeType.ALL)
	@JoinColumn(name="employee_Id")
	private Employee employee;

	public Degree(List<Object> params) {
		this.dateOfAssigment = (Date) params.get(0);
		this.kmn = (Boolean) params.get(1);
		this.dmn = (Boolean) params.get(2);

		Diplom diplom = new Diplom();
		diplom.setFaculty((String) params.get(3));
		diplom.setSeries(Integer.parseInt((String) params.get(4)));
		diplom.setDiplomNumber(Integer.parseInt((String) params.get(5)));
		diplom.setStartEducation((Date) params.get(6));
		diplom.setFinishEducation((Date) params.get(7));
		this.setDiplom(diplom);
	}

	public Degree() {
	}


	public Long getId() {
		return id;
	}

	public Date getDateOfAssigment() {
		return dateOfAssigment;
	}


	public Boolean getKmn() {
		return kmn;
	}


	public Boolean getDmn() {
		return dmn;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setDateOfAssigment(Date dateOfAssigment) {
		this.dateOfAssigment = dateOfAssigment;
	}

	public void setKmn(Boolean kmn) {
		this.kmn = kmn;
	}

	public void setDmn(Boolean dmn) {
		this.dmn = dmn;
	}

	public Diplom getDiplom() {
		return diplom;
	}

	public void setDiplom(Diplom diplom) {
		this.diplom = diplom;
	}

	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}



}
